package com.jia.leetCode;

import java.util.*;

public class Pro1436 {
    public String destCity(List<List<String>> paths) {
        Set<String> set = new HashSet<>();
        for(List<String> p : paths) {
            set.add(p.get(0));
        }
        for(List<String> p : paths) {
            if(!set.contains(p.get(1))) { return p.get(1); }
        }
        return  "";
    }

    public static void main(String[] args) {
        Pro1436 pro1436 = new Pro1436();
        List<List<String>> paths = new ArrayList<>();
        //[["London","New York"],["New York","Lima"],["Lima","Sao Paulo"]]
        paths.add(Arrays.asList("London", "New York"));
        paths.add(Arrays.asList("New York","Lima"));
        paths.add(Arrays.asList("Lima","Sao Paulo"));
        System.out.println(pro1436.destCity(paths));;
    }
}
